<%@ include file="/en/jsp/static.jsp" %>
<%@ page import="java.util.*,linuxbox.news.logic.*,linuxbox.BoxStatic" %>
<%@ taglib uri="/linuxbox/common.tld" prefix="common" %>

<jsp:include page="/en/jsp/header.jsp" flush="true"/>

<%
  int curPage = 0;
  String PAGE = (String) request.getParameter("PAGE");
  if (PAGE != null)
    curPage = Integer.parseInt(PAGE);

  BoxNews2 home = BoxNews2.getInstance();
  int entriesPerPage = sec.getConfigInt("news", "General", "Entries Per Page");
  int totalPage = home.getTotalPages(entriesPerPage, home.VT_CURRENT);
  String newsJSP = BoxStatic.jspDir+"news/BoxNews.jsp";
%>

<table width="100%" height=26 align=middle border=0 cellpadding=0 cellspacing=0 bgcolor="#f4f4f4" style="font-size:16px;color:#d05000">
  <tr>
    <td>
	    &nbsp;<img src="<%=BoxStatic.imageDir%>itemball.jpg" width=14 height=15 border=0 align="absmiddle">
	    <b><%=boxName%> - News&nbsp;</b>
    </td>
    <td align=right>
      <a href="<%=BoxStatic.servletDir%>BoxNewsSettingsAction?SubmitEdit=edit">
        Settings
      </a>
    </td>
  </tr>
</table>
<hr width=\"100%\" color=#E06000 align=left>

<table width="100%" border=0 cellpadding=4 cellspacing=0 style="font-size:14px">
<%
  List<BoxNewsEntry> it = home.getNews(BoxNews2.VT_CURRENT,
                  BoxNews2.ORDER_BY_SUBTIME, false, 
                  entriesPerPage*curPage, entriesPerPage);
  if (it != null) {
%>
  <tr>
    <td align=right>
      <common:Page curPage="<%=curPage%>" totalPage="<%=totalPage%>" action="<%=newsJSP%>" />
    </td>
  </tr>

  <tr><td><blockquote class="content">

<%
    int count = 0;
    for (BoxNewsEntry en : it) {
      out.println("<li><a href=\"#" + count + "\">["
        + en.getSubTimeString() + "] " + en.getSubject() +"</a></li>");
      count ++;
    }
    out.println("</blockquote></td></tr>");

    count = 0;
    for (BoxNewsEntry en : it) {
%>
      <tr><td class="Title" bgcolor="#f0f0f0">
        <img src="<%=BoxStatic.imageDir%>smallarrow.gif" align="absmiddle">
        <a name="<%=count%>"><%=en.getSubject()%>
          [<%= en.getSubTimeString()%>]
        </a>
      </td></tr>
      <tr><td>
		<blockquote class="Content"><%=en.getContent()%></blockquote>
      </td></tr>
<%
    }
%>
  <tr>
    <td align=right>
      <common:Page curPage="<%=curPage%>" totalPage="<%=totalPage%>" action="<%=newsJSP%>" />
    </td>
  </tr>
<%
  } else {
    out.print("<tr><td align=center>There is no News.</td></tr>");
  }
%>
  </table>
  <hr width=\"100%\" color=#E06000 align=left>

<jsp:include page="/en/jsp/footer.jsp" flush="true"/>
